package com.elink.enginerring.service.impl;

import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.elink.enginerring.common.ErrorType;
import com.elink.enginerring.dao.DetailCategoryMapper;
import com.elink.enginerring.dao.SecondaryCategoryMapper;
import com.elink.enginerring.dao.TopCategoryMapper;
import com.elink.enginerring.service.CategoryService;
import com.elink.enginerring.util.JSONUtil;

@Service("categoryServuice")
public class CategoryServiceImpl implements CategoryService {
	@Autowired
	private TopCategoryMapper topCategoryMapper;
	@Autowired
	private SecondaryCategoryMapper secondaryCategoryMapper;
	@Autowired
	private DetailCategoryMapper detailCategoryMapper;

	@Override
	public Map<String, Object> getTopCategory() {
		return JSONUtil.getJSON(ErrorType.SUCCESS,topCategoryMapper.selectList());
	}

	@Override
	public Map<String, Object> getSecondaryCategory(int tcId) {
		return JSONUtil.getJSON(ErrorType.SUCCESS,secondaryCategoryMapper.selectListByTcId(tcId));
	}
	
	@Override
	public Map<String, Object> getDetailCategory(int scId,int tcId) {
		if(tcId == 10){
			return JSONUtil.getJSON(ErrorType.SUCCESS);
		}else {
			return JSONUtil.getJSON(ErrorType.SUCCESS,detailCategoryMapper.selectListByScId(scId));
		}
	}
}
